package com.pickme.food.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pickme.food.mapper.StatsMapper;
import com.pickme.food.pojo.Stats;
import com.pickme.food.service.inte.StatsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class StatsServiceImpl extends ServiceImpl<StatsMapper, Stats> implements StatsService {

    /**
     * 查询统计的经营数据
     * @param beginTime
     * @param endTime
     */
    @Override
    public List<Stats> ListStats(Date beginTime, Date endTime) {
        LambdaQueryWrapper<Stats> wrapper = new LambdaQueryWrapper<>();
        wrapper.ge(beginTime != null,Stats::getStatsDate, beginTime);
        wrapper.le(endTime != null,Stats::getStatsDate,endTime);
        wrapper.orderByDesc(Stats::getStatsDate);
        return this.list(wrapper);
    }
}
